package com.hrt.demo.fannie.service.impl;

import java.sql.Timestamp;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.hrt.demo.fannie.bean.Classification;
import com.hrt.demo.fannie.dao.ClassificationDao;
import com.hrt.demo.fannie.service.ClassificationService;


@Service("classificationService")
public class ClassificationServiceImpl implements ClassificationService {
	private ClassificationDao classvificationDao;

	public ClassificationDao getClassvificationDao() {
		return classvificationDao;
	}
	@Resource
	public void setClassvificationDao(ClassificationDao classvificationDao) {
		this.classvificationDao = classvificationDao;
	}
	
	/**
	 * 保存实体
	 * */
	@Override
	public void addCS(Classification af) {
		try {
			this.classvificationDao.saveEntity(af);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	/**
	 * 更新实体
	 * */
	@Override
	public void updateCS(Classification af) {
		try {
			this.classvificationDao.updateEntity(af);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	/**
	 * 删除实体
	 * */
	@Override
	public void delCS(Long id) {
		try {
			this.classvificationDao.deleteEntity(id);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}

	/**
	 * 按id查询实体
	 * */
	@Override
	public Classification getById(Long id) {
		
		return this.classvificationDao.getById(id);
	}

	/**
	 * 查询所有
	 * */
	@Override
	public List<Classification> searchAll() {
		
		return this.classvificationDao.findAll();
	}

	/**
	 * 按id列表查询实体
	 * */
	@Override
	public List<Classification> getByIds(Long[] ids) {
		
		return this.classvificationDao.getByIds(ids);
	}

	/**分页*/
	@Override
	public Long totalCount() {
		
		return this.classvificationDao.totalCount();
	}
	
	@Override
	public List<Classification> queryByPage(int pageIndex, int pageSize) {
		
		return this.classvificationDao.queryByPage(pageIndex, pageSize);
	}
	/**获取数据库的当前Date形式的时间*/
	@Override
	public Timestamp getDate() {
		
		return this.classvificationDao.getDate();
	}
	
	/**删除选中的数据*/
	@Override
	public void deleteById(Long[] ids) throws Exception {
		List<Classification> delResult = this.classvificationDao.getByIds(ids);
		for(Classification cf : delResult){
			cf.setIsdelete(new Integer(1));
			this.classvificationDao.updateEntity(cf);
		}
	}
	
}
